package com.huawei;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by Z-hong on 2024/7/17.
 */

public class HJ41 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int weight[]=new int[count];
        int num[] = new int[count];

        for (int i = 0; i < count; i++) {
            weight[i] = sc.nextInt();
        }
        for (int i = 0; i < count; i++) {
            num[i] = sc.nextInt();
        }
        Set<Integer> set=new HashSet<>();
        set.add(0);
        for (int i = 0; i < count; i++) {
            Set<Integer> tempSet = new HashSet<>(set); // 创建临时集合
            for (int j = 0; j < num[i]; j++) {
                Set<Integer> newAdditions = new HashSet<>();
                for (Integer integer : tempSet) {
                    newAdditions.add(weight[i] + integer);
                }
                tempSet.addAll(newAdditions); // 在外部循环结束后统一添加
            }
            set.addAll(tempSet);
        }
        System.out.println(set.size());
    }
}
